home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / comms / internet / html-related / hsc / source / hsclib / hscprc.h < prev    next >
C/C++ Source or Header  |  1996-09-11  |  14KB  |  352 lines

  1. /*
  2.  * hsclib/hscprc.h
  3.  *
  4.  * hsc process structure
  5.  *
  6.  * Copyright (C) 1995,96  Thomas Aglassinger
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  */
  23.  
  24. #ifndef HSC_HSCPRC_H
  25. #define HSC_HSCPRC_H
  26.  
  27. #include <time.h>
  28.  
  29. #include "hsclib/ldebug.h"
  30. #include "hsclib/tag.h"
  31.  
  32. #include "hscprj/project.h"
  33.  
  34. typedef LONG HSCMSG_ID;         /* hsc message id */
  35. typedef LONG HSCMSG_CLASS;      /* hsc message class */
  36.  
  37. /*
  38.  * hsc process structure
  39.  */
  40. typedef struct hscprocess
  41. {
  42.     INFILE *inpf;               /* current input file */
  43.     DLLIST *inpf_stack;         /* stack of nested input files */
  44.     DLLIST *deftag;             /* defined tags and macros */
  45.     DLLIST *defattr;            /* defined attributes */
  46.     DLLIST *defent;             /* defined special charcters & entities */
  47.     DLLIST *container_stack;    /* stack of container-tags currently open */
  48.     HSCPRJ *project;            /* project data */
  49.     DLLIST *idrefs;             /* list of references to local IDs */
  50.     EXPSTR *destdir;            /* destination root directory */
  51.     EXPSTR *reldir;             /* relative destination directory */
  52.     EXPSTR *tmpstr;             /* temp. string used by several functions */
  53.     EXPSTR *rmt_str;            /* temp. string used for macro text */
  54.     EXPSTR *curr_msg;           /* current message */
  55.     EXPSTR *curr_ref;           /* current reference message */
  56.     EXPSTR *iconbase;           /* base URI for icons */
  57.     time_t start_time;          /* time process has been started */
  58.  
  59.     DLLIST *select_stack;       /* stack for results of <$select> */
  60.     EXPSTR *if_stack;           /* stack for results of <$if> */
  61.  
  62.     EXPSTR *tag_name_str;       /* strings for communication with tag-handlers */
  63.     EXPSTR *tag_attr_str;
  64.     EXPSTR *tag_close_str;
  65.  
  66. #if 0
  67.     STRPTR filename_project;    /* where to read/write project data */
  68. #endif
  69.     STRPTR filename_document;   /* document-name to be stored in project */
  70.  
  71.     BOOL *msg_ignore;           /* messages to be ignored */
  72.     HSCMSG_CLASS *msg_class;    /* messages with remaped classes */
  73.     ULONG msg_count;            /* numer of messages occured until now */
  74.  
  75.     BOOL chkid;                 /* flag: check existence of URIs/IDs */
  76.     BOOL chkuri;
  77.     BOOL compact;               /* flag: create compact output */
  78.     BOOL debug;                 /* flag: display debuging info */
  79.     BOOL getsize;               /* flag: get size of images/embedded docs */
  80.  
  81.     BOOL htmlonly;              /* flag: disable hsc-extensions */
  82.     BOOL jens;                  /* flag: enable some experimental features */
  83.     BOOL jerkvalues;            /* flag: interpret jerk values */
  84.     BOOL rplc_ent;              /* flag: replace special chars */
  85.     BOOL rplc_quote;            /* flag: replace quotes in text by """ */
  86.     BOOL smart_ent;             /* flag: replace special entities "<>&" */
  87.     BOOL strip_cmt;             /* flag: strip SGML-comments */
  88.     BOOL strip_ext;             /* flag: strip external references */
  89.  
  90.     BOOL suppress_output;
  91.     BOOL docbase_set;           /* <BASE HREF=".."> occured */
  92.     BOOL inside_pre;            /* inside preformatted tag <PRE> & Co. */
  93.     BOOL inside_anchor;         /* inside anchor-tag <A> */
  94.     BOOL inside_title;          /* inside title-tag <TITLE> */
  95.  
  96.     BOOL fatal;                 /* fatal error occured; abort process */
  97.  
  98.     LONG tag_call_id;
  99.     ULONG prev_status_line;
  100.     LONG prev_heading_num;      /* number of previous heading */
  101.     LONG entmode;               /* entity replace mode */
  102.     LONG quotemode;             /* quotes to use as output quotes */
  103.  
  104.     STRPTR click_here_str;      /* keywords for click-here syndrome */
  105.     STRPTR color_names;         /* predifined names for colors */
  106.     STRPTR strip_tags;          /* tags that should be stripped */
  107.     BOOL preceding_whtspc;      /* FLAG: white-space before tag? */
  108.     /*       CLUMSY! used by parse_tag() */
  109.     /* status callbacks */
  110.       VOID(*CB_status_misc) (struct hscprocess * hp, STRPTR s);
  111.     /* called for verbose messages */
  112.       VOID(*CB_status_line) (struct hscprocess * hp);
  113.     /* called after new line */
  114.       VOID(*CB_status_file_begin) (struct hscprocess * hp, STRPTR filename);
  115.     /* called when new file is going to be loaded */
  116.       VOID(*CB_status_file_end) (struct hscprocess * hp);
  117.     /* called after file has fully been processed */
  118.  
  119.     /* message callbacks */
  120.       VOID(*CB_message) (struct hscprocess * hp,
  121.                          HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
  122.                          STRPTR fname, ULONG x, ULONG y,
  123.                          STRPTR msg_text);
  124.       VOID(*CB_message_ref) (struct hscprocess * hp,
  125.                              HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
  126.                              STRPTR fname, ULONG x, ULONG y,
  127.                              STRPTR msg_text);
  128.  
  129.     /* syntax elements callbacks */
  130.       VOID(*CB_start_tag) (struct hscprocess * hp,
  131.           HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close);
  132.       VOID(*CB_end_tag) (struct hscprocess * hp,
  133.           HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close);
  134.       VOID(*CB_text) (struct hscprocess * hp,
  135.                       STRPTR white_spaces, STRPTR text);
  136.       VOID(*CB_id) (struct hscprocess * hp,
  137.                     HSCATTR * attr, STRPTR id);
  138. }
  139. HSCPRC;
  140.  
  141. #define HSCPREFS_ENVVAR  "HSCPREFS"     /* envvar that contains path for prefs */
  142. #define SPECIAL_FILE_ID  "::s::"        /* used as prefix in filename for */
  143.                                    /* internal (pseudo-)files (macros,init) */
  144. #define PARENT_FILE_ID  "::p::" /* used as prefix in filename if */
  145.               /* parent file on input-stack should be used for message-pos. */
  146.  
  147. /*
  148.  * system-dependant defines
  149.  */
  150. #ifdef AMIGA
  151. #define CONFIG_FILE "hsc.prefs"
  152. #define CONFIG_PATH "env:", "s:"
  153.  
  154. #elif defined UNIX
  155. #define CONFIG_FILE "hsc.prefs"
  156. #define CONFIG_PATH "/usr/local/lib/"
  157.  
  158. #elif defined WINNT
  159. #define CONFIG_FILE "hsc.prefs"
  160. #define CONFIG_PATH "\\"
  161.  
  162. #elif defined MSDOS
  163. #define CONFIG_FILE "HSC.PRE"
  164. #define CONFIG_PATH "\\"
  165.  
  166. #else
  167. #error "Operating system not supported: config-file/path"
  168. #endif
  169.  
  170. /* handle several OS-es same as MSDOS */
  171. #if (!defined MSDOS) & (defined WINNT)
  172. #define MSDOS
  173. #endif
  174.  
  175. /* step sizes for expstr's */
  176. #define ES_STEP_RMTSTR    32    /* tag_macr.c */
  177. #define ES_STEP_MACRO   1024    /* tag_macr.c */
  178. #define ES_STEP_INFILE  4096    /* input file buffer */
  179.  
  180. /*
  181.  * modes for syntax check
  182.  */
  183. #define MODE_PEDANTIC 1
  184. #define MODE_NORMAL   2
  185. #define MODE_RELAXED  3
  186.  
  187. /*
  188.  * modes for attribute quotes
  189.  */
  190. #define QMODE_KEEP   1          /* keep quotes from input */
  191. #define QMODE_DOUBLE 2          /* always use double quotes (compatible) */
  192. #define QMODE_SINGLE 3          /* always use single quotes */
  193. #define QMODE_NONE   4          /* never use any quotes (compact) */
  194.  
  195. /*
  196.  * modes for special characters/entity extraction
  197.  */
  198. #define EMODE_KEEP     1        /* do not replace */
  199. #define EMODE_REPLACE  2        /* replace by prefered value */
  200.                                 /*   (depends wheter if a PREFNUM was used */
  201.                                 /*   within $DEFENT) */
  202. #define EMODE_NUMERIC  3        /* always replace by numeric ({) */
  203. #define EMODE_SYMBOLIC 4        /* always replace by symbolic (ü) */
  204.  
  205. #define FILENAME_STDIN "STDIN"  /* pseudo-filename for stdin */
  206.  
  207. /* prefix char used for special hsc-tags  */
  208. #define HSC_SPECIAL_PREFIX "$"
  209.  
  210. /* attribute that holds "click here" words */
  211. #define CLICK_HERE_ATTR     "HSC.CLICK-HERE"
  212. #define COLOR_NAMES_ATTR    "HSC.COLOR-NAMES"
  213. #define ANCHOR_ATTR         "HSC.ANCHOR"
  214. #define RESULT_ATTR         "HSC.EXEC.RESULT"
  215. #define FILESIZEFORMAT_ATTR "HSC.FORMAT.FILESIZE"
  216. #define TIMEFORMAT_ATTR     "HSC.FORMAT.TIME"
  217. #define LINEFEED_ATTR       "HSC.LF"
  218.  
  219. /* attribute that hold condition on <$if/$elseif> */
  220. #define CONDITION_ATTR "COND"
  221.  
  222. /* attribute that tells operating system */
  223. #define SYSTEM_ATTR     "HSC.SYSTEM"
  224. #ifdef AMIGA
  225. #define SYSTEM_ATTR_ID "AMIGA"
  226. #elif defined UNIX
  227. #define SYSTEM_ATTR_ID "UNIX"
  228. #elif defined MSDOS
  229. #define SYSTEM_ATTR_ID "KILLBILL"
  230. #else
  231. #error "system not supported: SYSTEM_ATTR_ID"
  232. #endif
  233.  
  234. /*
  235.  * global funcs
  236.  */
  237. #ifndef NOEXTERN_HSC_HSCPRC
  238.  
  239. extern VOID del_hscprc(HSCPRC * hp);
  240. extern HSCPRC *new_hscprc(void);
  241.  
  242. /* set-methodes for callbacks */
  243. extern VOID hsc_set_status_file_begin(HSCPRC * hp, VOID(*status_file) (HSCPRC * hp, STRPTR filename));
  244. extern VOID hsc_set_status_file_end(HSCPRC * hp, VOID(*status_file) (HSCPRC * hp));
  245. extern VOID hsc_set_status_line(HSCPRC * hp, VOID(*status_line) (HSCPRC * hp));
  246. extern VOID hsc_set_status_misc(HSCPRC * hp, VOID(*status_misc) (HSCPRC * hp, STRPTR s));
  247. extern VOID hsc_set_message(HSCPRC * hp,
  248.                             VOID(*message) (struct hscprocess * hp,
  249.                                             HSCMSG_CLASS msg_class,
  250.                                             HSCMSG_ID,
  251.                                             STRPTR fname, ULONG x, ULONG y,
  252.                                             STRPTR msg_text));
  253. extern VOID hsc_set_message_ref(HSCPRC * hp,
  254.                                 VOID(*message_ref) (struct hscprocess * hp,
  255.                                                     HSCMSG_CLASS msg_class,
  256.                                                     HSCMSG_ID msg_id,
  257.                                                     STRPTR fname,
  258.                                                     ULONG x, ULONG y,
  259.                                                     STRPTR msg_text));
  260. extern VOID hsc_set_start_tag(HSCPRC * hp,
  261.                               VOID(*CB_start_tag) (struct hscprocess * hp,
  262.                                                    HSCTAG * tag,
  263.                                                    STRPTR tag_name,
  264.                                                    STRPTR tag_attr,
  265.                                                    STRPTR tag_close));
  266. extern VOID hsc_set_end_tag(HSCPRC * hp,
  267.                             VOID(*CB_end_tag) (struct hscprocess * hp,
  268.                                                HSCTAG * tag,
  269.                                                STRPTR tag_name,
  270.                                                STRPTR tag_attr,
  271.                                                STRPTR tag_close));
  272. extern VOID hsc_set_text(HSCPRC * hp,
  273.                          VOID(*CB_text) (struct hscprocess * hp,
  274.                                          STRPTR white_spaces, STRPTR text));
  275. extern VOID hsc_set_id(HSCPRC * hp,
  276.                        VOID(*id) (struct hscprocess * hp,
  277.                                   HSCATTR * attr, STRPTR id));
  278.  
  279. /* set-methodes for flags */
  280. extern VOID hsc_set_chkid(HSCPRC * hp, BOOL new_chkid);
  281. extern VOID hsc_set_chkuri(HSCPRC * hp, BOOL new_chkuri);
  282. extern VOID hsc_set_compact(HSCPRC * hp, BOOL new_compact);
  283. extern VOID hsc_set_debug(HSCPRC * hp, BOOL new_debug);
  284. extern VOID hsc_set_getsize(HSCPRC * hp, BOOL new_getsize);
  285. extern VOID hsc_set_htmlonly(HSCPRC * hp, BOOL new_jens);
  286. extern VOID hsc_set_jens(HSCPRC * hp, BOOL new_jens);
  287. extern VOID hsc_set_jerkvalues(HSCPRC * hp, BOOL new_jens);
  288. extern VOID hsc_set_rplc_ent(HSCPRC * hp, BOOL new_rplc_ent);
  289. extern VOID hsc_set_rplc_quote(HSCPRC * hp, BOOL new_rplc_quote);
  290. extern VOID hsc_set_smart_ent(HSCPRC * hp, BOOL new_smart_ent);
  291. extern VOID hsc_set_strip_cmt(HSCPRC * hp, BOOL new_strip_cmt);
  292. extern VOID hsc_set_strip_ext(HSCPRC * hp, BOOL new_strip_ext);
  293.  
  294. /* set-methodes for values */
  295. extern BOOL hsc_set_destdir(HSCPRC * hp, STRPTR dir);
  296. extern BOOL hsc_set_reldir(HSCPRC * hp, STRPTR fname);
  297. extern BOOL hsc_set_iconbase(HSCPRC * hp, STRPTR uri);
  298. extern BOOL hsc_set_filename_document(HSCPRC * hp, STRPTR filename);
  299. extern VOID hsc_set_quote_mode(HSCPRC * hp, LONG new_mode);
  300. extern VOID hsc_set_entity_mode(HSCPRC * hp, LONG new_mode);
  301.  
  302. /* get-methodes for flags */
  303. extern BOOL hsc_get_chkid(HSCPRC * hp);
  304. extern BOOL hsc_get_chkuri(HSCPRC * hp);
  305. extern BOOL hsc_get_compact(HSCPRC * hp);
  306. extern BOOL hsc_get_debug(HSCPRC * hp);
  307. extern BOOL hsc_get_getsize(HSCPRC * hp);
  308. extern BOOL hsc_get_htmlonly(HSCPRC * hp);
  309. extern BOOL hsc_get_jerkvalues(HSCPRC * hp);
  310. extern BOOL hsc_get_jens(HSCPRC * hp);
  311. extern BOOL hsc_get_rplc_ent(HSCPRC * hp);
  312. extern BOOL hsc_get_rplc_quote(HSCPRC * hp);
  313. extern BOOL hsc_get_smart_ent(HSCPRC * hp);
  314. extern BOOL hsc_get_strip_cmt(HSCPRC * hp);
  315. extern BOOL hsc_get_strip_ext(HSCPRC * hp);
  316.  
  317. /* get-methodes for internal flags */
  318. extern BOOL hsc_get_fatal(HSCPRC * hp);
  319. extern BOOL hsc_get_inside_anchor(HSCPRC * hp);
  320. extern BOOL hsc_get_inside_pre(HSCPRC * hp);
  321. extern BOOL hsc_get_suppress_output(HSCPRC * hp);
  322.  
  323. /* get-methodes for values */
  324. extern STRPTR hsc_get_destdir(HSCPRC * hp);
  325. extern STRPTR hsc_get_reldir(HSCPRC * hp);
  326. extern STRPTR hsc_get_iconbase(HSCPRC * hp);
  327.  
  328. /* get-methodes for internal values */
  329. extern STRPTR hsc_get_click_here_str(HSCPRC * hp);
  330. extern STRPTR hsc_get_file_name(HSCPRC * hp);
  331. extern ULONG hsc_get_file_line(HSCPRC * hp);
  332. extern ULONG hsc_get_file_column(HSCPRC * hp);
  333. extern ULONG hsc_get_msg_count(HSCPRC * hp);
  334.  
  335. /* methodes for messages */
  336. extern BOOL hsc_set_msg_ignore(HSCPRC * hp, HSCMSG_ID msg_id, BOOL value);
  337. extern BOOL hsc_get_msg_ignore(HSCPRC * hp, HSCMSG_ID msg_id);
  338. extern BOOL hsc_set_msg_class(HSCPRC * hp, HSCMSG_ID msg_id, HSCMSG_CLASS msg_class);
  339. extern HSCMSG_CLASS hsc_get_msg_class(HSCPRC * hp, HSCMSG_ID msg_id);
  340. extern VOID hsc_clear_msg_ignore(HSCPRC * hp);
  341. extern VOID hsc_reset_msg_class(HSCPRC * hp);
  342.  
  343. /* output function */
  344. extern BOOL hsc_output_text(HSCPRC * hp, STRPTR wspc, STRPTR text);
  345.  
  346. /* misc. functions */
  347. extern BOOL hsc_standard_nomem_handler(size_t size);
  348.  
  349. #endif /* NOEXTERN_HSC_HSCPRC */
  350. #endif /* HSC_HSCPRC_H */
  351.  
  352.